local skill = fk.CreateSkill {
  name = "hanqing__lianke__fire_attack_skill",
}

Fk:loadTranslationTable{
  ["hanqing__lianke__fire_attack_skill"] = "火攻",
  ["#hanqing__lianke__fire_attack-discard"] = "你可弃置一张手牌，对 %src 造成1点火属性伤害",
}

skill:addEffect("cardskill", {
  mute = true,
  prompt = "#fire_attack_skill",
  target_num = 1,
  mod_target_filter = function(self, _, to_select, _, _, _)
    return not to_select:isKongcheng()
  end,
  target_filter = Util.CardTargetFilter,
  on_effect = function(self, room, effect)
    local from = effect.from
    local to = effect.to
    if to:isKongcheng() then return end

    local params = { ---@type AskToCardsParams
      min_num = 1,
      max_num = 1,
      include_equip = false,
      skill_name = "fire_attack_skill",
      cancelable = false,
      pattern = ".|.|.|hand",
      prompt = "#fire_attack-show:" .. from.id
    }
    local showCard = room:askToCards(to, params)[1]
    to:showCards(showCard)

    showCard = Fk:getCardById(showCard)
    local pattern = ".|.|" .. showCard:getSuitString()
    local banner = room:getBanner("hanqing__lianke-phase") or {}
    if #banner > 0 then
      room:showCards(banner)
      for _, id in ipairs(banner) do
        local suit = Fk:getCardById(id):getSuitString()
        if suit ~= "nosuit" then
          pattern = pattern .. "," .. suit
        end
      end
    end
    params = { ---@type AskToDiscardParams
      min_num = 1,
      max_num = 1,
      include_equip = false,
      skill_name = "fire_attack_skill",
      cancelable = true,
      pattern = pattern,
      prompt = "#hanqing__lianke__fire_attack-discard:" .. to.id,
    }
    local cards = room:askToDiscard(from, params)
    local damageDealt = false
    if #cards > 0 and not to.dead then
      if room:damage({
        from = from,
        to = to,
        card = effect.card,
        damage = 1,
        damageType = fk.FireDamage,
        skillName = "fire_attack_skill",
      }) then
        damageDealt = true
      end
    end
    if damageDealt then
      table.insertIfNeed(banner, showCard.id)
      room:setBanner("hanqing__lianke-phase", banner)
    else
      room:setBanner("hanqing__lianke-phase", {})
    end
  end,
})

return skill
